package com.pidan.util;

import com.pidan.pojo.Product;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class IOutil {

    public static void output(Object object) throws IOException {
        String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        //序列化存储到磁盘
        ObjectOutputStream oo = new ObjectOutputStream(new FileOutputStream("F:/tbk/data/" + date + ".data"));
        oo.writeObject(object);
        oo.close();
    }

    public static List<Product> input(String path) throws IOException, ClassNotFoundException {
        ObjectInputStream oi = new ObjectInputStream  (new FileInputStream(path));
        List<Product> list = (List<Product>) oi.readObject();
        oi.close();
        return list;
    }
}
